<div id="blog">
<h2>All Needs</h2>
<div class="posts" id="posts">
<?php 
$siteid = $site['id'];
$postsqry = dbSelect('posts',array("site_id=$siteid","parent_id=0","type_id=3 or type_id=4 or type_id=5 or type_id=6"),"ORDER BY publishdate DESC");
if(mysql_numrows($postsqry) > 0){ 
	while($posts = mysql_fetch_array($postsqry)){
		$userid = $posts['author_id'];
		$author = mysql_fetch_array(dbSelect('users',array("id=$userid")));
		$authorname = $author['firstname'].' '.$author['lastname'];
		$nicetime = nicetime($posts['publishdate']);
?>
	<div class="post">
		<span id="post_author"><?php echo $authorname; ?></span>&nbsp;
		<div id="post_body"><?php echo urldecode($posts['post']); ?></div>
		<div id="post_datetime"><?php if($nicetime){echo $nicetime;} ?></div>
		<div class="comments">
			<?php 
			$commentsparentid = $posts['id'];
			$commentsqry = dbSelect('posts',array("site_id=$siteid","parent_id=$commentsparentid"));
			if(mysql_numrows($commentsqry) > 0){
				while($comments = mysql_fetch_array($commentsqry)){
					$userid = $comments['author_id'];
					$commentsauthor = mysql_fetch_array(dbSelect('users',array("id=$userid")));
					$commentsauthorname = $commentsauthor['firstname'].' '.$commentsauthor['lastname'];
					$commentsnicetime = nicetime($comments['publishdate']);
			?>
					<div class="comment rounded_comments">
						<span id="comment_author"><?php echo $commentsauthorname; ?></span>
						<div id="comment_body"><?php echo urldecode($comments['post']); ?></div>
						<div id="comment_datetime"><?php echo $commentsnicetime; ?></div>
					</div>
			<?php
				} /* /while comments */
			}  /* /if comments */
			?>
		</div><!--/comments-->
	</div><!--/post-->
<?php
	} /* /while posts */
} /* /if posts */
?>
</div><!--/posts-->
</div><!--/blog-->